//
//  MOFSBottomView.m
//  fitnessmanage
//
//  Created by wujian on 2017/11/24.
//  Copyright © 2017年 zongquankeji. All rights reserved.
//

#import "MOFSBottomView.h"

@implementation MOFSBottomView

-(id)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        UIView *horLineView = [[UIView alloc] init];
        horLineView.backgroundColor = LineBackGroundColor;
        [self addSubview:horLineView];
        self.horLineView = horLineView;
        
        UIButton *cancleBtn = [[UIButton alloc] init];
        cancleBtn.backgroundColor = CSWhiteColor;
        [cancleBtn addTarget:self action:@selector(cancelAction)];
        [cancleBtn setTitle:@"取消"];
        cancleBtn.titleLabel.font = MidBigFont;
        [cancleBtn setTitleColor:CSBlackColor];
        [self addSubview:cancleBtn];
        self.cancleBtn = cancleBtn;
        
//        UIView *verLineView = [[UIView alloc] init];
//        verLineView.backgroundColor = LineBackGroundColor;
//        [self addSubview:verLineView];
//        self.verLineView = verLineView;
        
        UIButton *sureBtn = [[UIButton alloc] init];
        [sureBtn addTarget:self action:@selector(commitAction)];
        [sureBtn setTitle:@"确定"];
        sureBtn.titleLabel.font = MidBigFont;
        sureBtn.backgroundColor = ButtonBackGroundColor;
        [sureBtn setTitleColor:CSColorFromRGB(0x0a0a0a)];
        [self addSubview:sureBtn];
        self.sureBtn = sureBtn;
        
        [self setConstraints];
    }
    
    return self;
    
}

-(void)setConstraints{
    
    [self.horLineView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.left.mas_equalTo(self);
        make.width.mas_equalTo(self.cancleBtn);
        make.height.mas_equalTo(1);
    }];
    
//    [self.verLineView mas_remakeConstraints:^(MASConstraintMaker *make) {
//
//        make.top.height.mas_equalTo(self);
//        make.width.mas_equalTo(1);
//        make.centerX.mas_equalTo(self);
//    }];
    
    [self.cancleBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.left.bottom.mas_equalTo(self);
        make.top.mas_equalTo(self.horLineView.mas_bottom);
        //make.right.mas_equalTo(self.mas_centerX);
        make.height.mas_equalTo(60);
    }];
    
    [self.sureBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self);
        make.right.bottom.mas_equalTo(self);
        make.left.mas_equalTo(self.cancleBtn.mas_right);
        make.width.mas_equalTo(self.cancleBtn);
    }];
}

#pragma mark - Action

- (void)cancelAction {
    if (self.cancelBlock) {
        self.cancelBlock();
    }
}

- (void)commitAction {
    if (self.commitBlock) {
        self.commitBlock();
    }
}

@end
